public class Test {
    /*
    括号生成
    class Solution {
    List<String> ret;
    StringBuffer path;

    int left = 0, right = 0 ;
    public List<String> generateParenthesis(int n) {
        ret = new ArrayList<>();
        path = new StringBuffer();
        dfs(n);
        return ret;
    }
    void dfs(int n) {
        //当 右括号 等于 n 找到一个
        if(right == n) {
            ret.add(path.toString());
            return ;
        }
        // 先找左括号
        if(left < n) {
            path.append("(");
            left++;
            dfs(n);
            //回退
            path.deleteCharAt(path.length()-1);
            left--;
        }
        //找完左括号 找右括号
        if(right < left ) {
            path.append(")");
            right++;
            dfs(n);
            //回退
            path.deleteCharAt(path.length()-1);
            right--;
        }
    }

}
    只出现一次的数字 II
    class Solution {
    public int singleNumber(int[] nums) {
        Map<Integer,Integer> hash = new HashMap<>();
        for(int x : nums) {
            hash.put(x , hash.getOrDefault(x , 0) + 1);
        }
        for(int i = 0 ; i < nums.length ;i++) {
            if(hash.get(nums[i]) == 1) {
                return nums[i];
            }
        }
        return 0;
    }
}
    设计机械累加器
    class Solution {
    int sum = 0;
    public int mechanicalAccumulator(int target) {
        boolean x = target > 1 && mechanicalAccumulator(target - 1) > 0;
        sum += target;
        return sum;
    }
}
    验证图书取出顺序
    class Solution {
    public boolean validateBookSequences(int[] putIn, int[] takeOut) {
        int i = 0, j = 0;
        for (int x : putIn) {
            putIn[i] = x;
            while (i >= 0 && putIn[i] == takeOut[j]) {
                i--;
                j++;
            }
            i++;
        }
        return i == 0;
    }
}
     */
}
